package org.bigmarketapi.projectreview.PrefixTree;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: API-GateWay
 * @BelongsPackage: org.bigmarketapi.apigateway.Session.PrefixTree
 * @Author: dujiaqi
 * @CreateTime: 2024-11-27  22:15
 * @Description: TODO 首先利用String后再进行泛型抽象
 * @Version: 1.0
 */
@Data
public class TreeNode {
    String pathSegment;
    //新增父节点指针
    TreeNode parent;
    List<TreeNode> children;

    public TreeNode(String pathSegment) {
        this.pathSegment = pathSegment;
        this.children = new ArrayList<>();
    }

    public void addChild(TreeNode childNode) {
        childNode.parent = this;
        if (!this.children.contains(childNode)) {
            this.children.add(childNode);
        }
    }


}
